package com.youxuit.youxu.kecheng.threadLocal.usage2;

public class ThreadLocalNPE {
    public static ThreadLocal<Long> holder = new ThreadLocal<>();

    public void set() {
        this.holder.set(Thread.currentThread().getId());
    }

    public long get() {
        return this.holder.get();
    }

    public static void main(String[] args) {
        /*ThreadLocalNPE threadLocalNPE = new ThreadLocalNPE();
        threadLocalNPE.set();
        System.out.println(threadLocalNPE.get());*/


        ThreadLocalNPE threadLocalNPE = new ThreadLocalNPE();
        System.out.println(threadLocalNPE.get());

        new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadLocalNPE threadLocalNPE = new ThreadLocalNPE();
                threadLocalNPE.set();
                System.out.println(threadLocalNPE.get());
            }
        }).start();
    }

}